import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'HomePage',
      meta: { requiresAuth: true }, // 标记首页需要登录
      props: route => ({
        userId: route.query.userId
      }),
      component: () => import('../views/HomePage.vue')
    },
    {
      path: '/VideoChat',
      name: 'VideoChat',
      meta: { requiresAuth: true }, // 标记首页需要登录
      props: route => ({
        role: route.query.role,
        targetUserId: route.query.targetUserId
      }),
      component: () => import('../views/VideoChat.vue')
    },
    {
      path: '/moments',
      name: 'MomentsPage',
      meta: { requiresAuth: true }, // 标记首页需要登录
      component: () => import('../views/moments/MainPage.vue')
    },
    {
      path: '/postMoment',
      name: 'PostPage',
      meta: { requiresAuth: true }, // 标记首页需要登录
      component: () => import('../views/moments/Post.vue')
    },
    {
      path: '/momentDetail',
      name: 'MomentDetail',
      meta: { requiresAuth: true }, // 标记首页需要登录
      component: () => import('../views/moments/MomentDetail.vue')
    },
    {
      path: '/userMoments',
      name: 'userMoments',
      meta: { requiresAuth: true }, // 标记首页需要登录
      component: () => import('../views/moments/UserPage.vue')
    },
    {
      path: '/momentNotice',
      name: 'NoticePage',
      meta: { requiresAuth: true }, // 标记首页需要登录
      component: () => import('../views/moments/NoticePage.vue')
    },
    {
      path: '/MyHomePage',
      name: 'MyHomePage',
      props: true,
      meta: { requiresAuth: true }, // 标记首页需要登录
      component: () => import('../views/MyHomePage.vue')
    },
    {
      path: '/Register',
      name: 'Register',
      props: true,
      meta: { requiresAuth: false }, // 标记登录页不需要登录
      component: () => import('../views/Register.vue')
    },
    {
      path: '/Login',
      name: 'Login',
      props: true,
      meta: { requiresAuth: false }, // 标记注册页不需要登录
      component: () => import('../views/Login.vue')
    },
    {
      path: '/SmsLogin',
      name: 'SmsLogin',
      props: true,
      meta: { requiresAuth: false }, // 标记登录页不需要登录
      component: () => import('../views/SmsLogin.vue')
    },
    {
      path: '/PersonalDataVue',
      name: 'PersonalDataVue',
      props: true,
      meta: { requiresAuth: true }, // 标记登录页需要登录
      component: () => import('../views/PersonalDataVue.vue')
    },
    {
      path: '/Modification',
      name: 'Modification',
      props: true,
      meta: { requiresAuth: true }, // 标记登录页需要登录
      component: () => import('../views/Modification.vue')
    },
    {
      path: '/discover',
      name: 'discover',
      meta: { requiresAuth: true }, // 标记首页需要登录
      component: () => import('../views/DiscoverView.vue')
    },
    {
      path: '/videoview',
      name: 'videoview',
      meta: { requiresAuth: true }, // 标记首页需要登录
      component: () => import('../views/VideoView.vue')
    },
    {
      path: '/addfrienddetail',
      name: 'addfrienddetail',
      meta: { requiresAuth: true }, // 标记首页需要登录
      component: () => import('../components/address/AddFriendDetail.vue')
    },
    {
      path: '/addFriend',
      name: 'addFriend',
      meta: { requiresAuth: true }, // 标记首页需要登录
      component: () => import('../components/address/AddFriend.vue')
    },
    {
      path: '/newFriend',
      name: 'newFriend',
      meta: { requiresAuth: true }, // 标记首页需要登录
      component: () => import('../components/address/NewFriend.vue')
    },
    {
      path: '/addFriendRequest',
      name: 'addFriendRequest',
      meta: { requiresAuth: true }, // 标记首页需要登录
      component: () => import('../components/address/AddFriendRequest.vue')
    },
    {
      path: '/SearchToView',
      name: 'SearchToView',
      meta: { requiresAuth: true }, // 标记首页需要登录
      component: () => import('../components/address/SearchToView.vue')
    },
    {
      path: '/AddressView',
      name: 'AddressView',
      meta: { requiresAuth: true }, // 标记首页需要登录
      component: () => import('../components/address/AddressView.vue')
    },
    {
      path: '/discover',
      name: 'discover',
      meta: { requiresAuth: true }, // 标记首页需要登录
      component: () => import('../views/DiscoverView.vue')
    },
    { //聊天列表
      path: '/chatList11',
      name: 'chatList11',
      meta: { requiresAuth: true }, // 标记首页需要登录
      component: () => import('../components/ChatComponents/chatList11.vue')
    },
    {  //聊天详情
      path: '/ChatDetail',
      name: 'ChatDetail',
      meta: { requiresAuth: true }, // 标记首页需要登录
      component: () => import('../components/ChatComponents/ChatDetail.vue')
    },
    {
      path: '/videoperson',
      name: 'videoperson',
      component: () => import('../views/MyVideoChannel.vue')
    },
    {
      path: '/personalvideo',
      name: 'personalvideo',
      component: () => import('../views/PersonVideo.vue')
    }
  ],
})

export default router
